import json

from ronglian_sms_sdk import SmsSDK

from djangoProject.settings import RONG_LIAN_YUN_CLASS


def send_message(tid, phone, content):
    rong_lian_yun_class = RONG_LIAN_YUN_CLASS
    sdk = SmsSDK(rong_lian_yun_class.get('accId'), rong_lian_yun_class.get('accToken'),
                 rong_lian_yun_class.get('appId'))
    result = sdk.sendMessage(tid, phone, content)
    print('------------result------------')
    print(result)
    result = json.loads(result)  # 将json格式的字符串转换为python字典
    if result['statusCode'] == '000000':
        print('短信发送成功')
        return True
    else:
        print('短信发送失败')
        return False
